﻿"use strict";

window.ArthurGraus = window.ArthurGraus || {};

var youTube;

$(document).ready(function () {
    youTube = new ArthurGraus.YouTube();
    youTube.initialize();
});

ArthurGraus.YouTube = function () {
    var self = this;
    self.adRotator = null;
    self.analytics = null;
    self.step = 1;
    self.numberOfSteps = 0;
    self.initialize = function () {
        self.adRotator = new ArthurGraus.AdRotator('YOTU', 10000, 'adRotator', 1);
        self.adRotator.initialize();

        self.analytics = new ArthurGraus.Analytics('YOTU');
        self.analytics.initialize();

        $('.instructionStep').hide();
        $('#step1').show();
        $('.nextStep').click(self.nextStep_Click);
        $('.previousStep').click(self.previousStep_Click);

        self.numberOfSteps = $('.instructionStep').length;
    };

    self.nextStep_Click = function () {
        $('#step' + self.step).hide();
        self.step = self.step + 1;

        if (self.step > self.numberOfSteps) {
            self.step = self.numberOfSteps;
        }
        $('#step' + self.step).show();

    };
    self.previousStep_Click = function () {
        $('#step' + self.step).hide();
        self.step = self.step - 1;

        if (self.step < 1) {
            self.step = 1;
        }

        $('#step' + self.step).show();
    };

};

function getQuerystring(key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(window.location.href);
    if (qs == null)
        return default_;
    else
        return qs[1];
}
function getQuerystringFromString(url, key, default_) {
    if (default_ == null) default_ = "";
    key = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
    var qs = regex.exec(url);
    if (qs == null)
        return default_;
    else
        return qs[1];
}

function htmlEscape(str) {
    return String(str)
            .replace(/&/g, '&amp;')
            .replace(/"/g, '&quot;')
            .replace(/'/g, '&#39;')
            .replace(/</g, '&lt;')
            .replace(/>/g, '&gt;')
            .replace(/ /g, '&nbsp;')
            .replace(/\n/g, '<br />');
}





